package com.ctw.mapmycity;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.ctw.mapmycity.model.CustomMarker;
import com.google.android.gms.maps.GoogleMap.InfoWindowAdapter;
import com.google.android.gms.maps.model.Marker;

public class CustomInfoWindowAdpater implements InfoWindowAdapter {

	private LayoutInflater mInflater;
	Activity activity;
	CustomMarker customMarker = null;
	
	public CustomInfoWindowAdpater(LayoutInflater inflater,Activity activity) {
	    this.mInflater=inflater;
	    this.activity = activity;
	}
	
	  @Override
	  public View getInfoWindow(Marker marker) {
	    return(null);
	  }

	  @Override
	  public View getInfoContents(Marker marker) {
		String snippet = marker.getSnippet();
		String [] snippetAddress = null;
		if (snippet != null){
			snippetAddress = snippet.split(";");	
		}
//		customMarker =  ((MapMyCity) activity.getApplication()).listCustomOptionMarkers.get(((MapMyCity) activity.getApplication()).listCustomOptionMarkers.size() -1);
		View popup=mInflater.inflate(R.layout.info_window, null);
	    
	    TextView tv=(TextView)popup.findViewById(R.id.title);
	    if (snippetAddress != null)
	    tv.setText(snippetAddress[1]);
	   
	    tv=(TextView)popup.findViewById(R.id.snippet);
	    if (snippetAddress != null)
	    tv.setText(snippetAddress[0]);
	    
	    tv=(TextView)popup.findViewById(R.id.crime);
	    if (snippetAddress != null)
	    tv.setText(snippetAddress[2]);
	   
	    tv=(TextView)popup.findViewById(R.id.description);
	    if (snippetAddress != null)
	    tv.setText("Description: " + snippetAddress[6]);
	    
	    tv=(TextView)popup.findViewById(R.id.date);
	    if (snippetAddress != null)
	    tv.setText(snippetAddress[4] + " - " + snippetAddress[5]);
	    

	    
	    return(popup);
	  }

}
